import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"; // vuex 状态持久化
import user from './modules/user.js'
import menu from './modules/menu.js'
import other from './modules/other.js'

Vue.use(Vuex);

const store = new Vuex.Store({
	plugins: [createPersistedState({
		storage: window.sessionStorage, // 表示缓存到 sessionStorage
	})],
	state: {
		token: '',
		asideWidth: '205px',
		collapsed: false, // 是否水平折叠收起菜单
		rolelist: [],
		btnPermissions: [],
		typelist: [{
			id: '123',
			name: '运营专员'
		}, {
			id: '456',
			name: '客户账号'
		}],
		testAccount: [{
				id: 1,
				name: '测试账号 一',
				check: false,
			},
			{
				id: 2,
				name: '测试账号 二',
				check: false,
			},
			{
				id: 3,
				name: '测试账号 三',
				check: false,
			},
			{
				id: 4,
				name: '测试账号 四',
				check: false,
			},
			{
				id: 5,
				name: '测试账号 五',
				check: false,
			},
			{
				id: 1,
				name: '测试账号 六',
				check: false,
			},
			{
				id: 6,
				name: '测试账号 七',
				check: false,
			},
			{
				id: 7,
				name: '测试账号 八',
				check: false,
			}
		]
	},
	modules: {
		user,
		menu,
		other
	},
	mutations: {
		setCollapsed: (state, val) => {
			state.collapsed = val;
			state.asideWidth = val ? 'auto' : '205px'
		},
		setToken: (state, val) => {
			state.token = val
		},
		setRoleList: (state, val) => {
			state.rolelist = val
		},
		setBtnPermissions: (state, val) => {
			state.btnPermissions = val
		}
		
	},
	actions: {
		
	}
})


export default store;
